package day1126;

import java.util.Timer;
import java.util.TimerTask;

class  Ball{
    int  height=0;
    void moveUp(){
        height++;
        System.out.println(height);
    }
}

public class Demo15 {
    public static void main(String[] args) {
        Ball  b=new Ball();

        TimerTask  task=new TimerTask() {
            public void run() {
                b.moveUp();
            }
        };//1.

        //2.
        Timer t=new Timer();
        t.schedule(task, 2000, 2000);
    }
}
